package com.learn.mq.listener;

import com.learn.mq.beans.Person;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageConst;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import java.util.function.Consumer;

/**
 * ClassName:Listener1
 * Package:com.learn.mq.listener
 * Description:
 *
 * @Author:@郭先森
 * @Create:2025/7/30 - 21:14
 * @Version:v1.0
 */
@Slf4j
@Configuration
public class Listener1 {
    @Bean
    public Consumer<Message<Person>> hello() {
        return message -> {
            String tag = message.getHeaders().get("MESSAGE_TAG", String.class);
            log.info("收到了消息，收到的消息的tag为："+tag);
            Person person = message.getPayload();
            log.info("解析出来的消息体为: "+person);
        };
    }
}
